package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;

public class OSWDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("ows.txt");
        //创建转换流时通常会指定第二个参数来明确字符集，以此来保证跨平台性
        OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
        osw.write("秋水共长天一色，落霞与孤鹜齐飞。");
        osw.write("李桑，家乡的撒库拉开了。");
        System.out.println("写出完毕");
        osw.close();//关闭高级流时会自动关闭低级流，关闭低级流关闭不了高级流
    }
}
